﻿using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Web.Services;
using PPIDataAccess.Data;
using System.Drawing;
using System.IO;
using System.Net;

namespace PPIWebService
{
    [WebService(Namespace = "http://www.dev-poleposition.com/Dev/WebService/",
        Description = "POLE POSITION WEBSERVICE.")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    public class PPIWebServiceClass : WebService
    {



        [WebMethod]
        public bool SaveImage(string root, byte[] bytes)
        {
            FileInfo _FeatureFile = new FileInfo(Server.MapPath("") + root);
            DirectoryInfo d = new DirectoryInfo(_FeatureFile.DirectoryName);
            if(!d.Exists)
                d.Create();
            MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length);
            Image _NewImage = Image.FromStream(ms);
            _NewImage.Save(_FeatureFile.FullName);
            return _FeatureFile.Length > 0;
           
        }

        #region LookUp

        [WebMethod]
        public DataSet Lookup_SelectAllbyType(string type, string connectionKey)
        {
            return DLookup.SelectAllbyType(type, connectionKey);
        }

        #endregion

        #region Utility

        [WebMethod]
        public DataSet Utility_SelectAllIdName(string connectionKey)
        {
            return DUtility.SelectAllIdName(connectionKey);
        }

        #endregion

        #region Utility_Asset_XMissionStructure

        [WebMethod]
        public DataSet Utility_Asset_XMissionStructure_SelectAllServer(string connectionKey)
        {
            return DUtility_Asset_XMissionStructure.SelectAllServer(connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Asset_XMissionStructure_SelectAllServerByUtilty(int utilityID, string connectionKey)
        {
            return DUtility_Asset_XMissionStructure.SelectAllServer(utilityID, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Asset_XMissionStructure_SelectAllIdName(string connectionKey)
        {
            return DUtility_Asset_XMissionStructure.SelectAllIdName(connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Asset_XMissionStructure_SelectUtilityNearVendor(Int32 vendorId, Int32 maxDistance, string connectionKey)
        {
            return DUtility_Asset_XMissionStructure.SelectUtilityNearVendor(vendorId, maxDistance, connectionKey);
        }

        [WebMethod]
        public void Utility_Asset_XMissionStructure_CreateNewByVendor(int vendorId, string connectionKey)
        {
            DUtility_Asset_XMissionStructure.NewByVendor(vendorId, connectionKey);
        }

        [WebMethod]
        public void Utility_Asset_XMissionStructure_Delete(int utilityId, string connectionKey)
        {
            DUtility_Asset_XMissionStructure.Delete(utilityId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Asset_XMissionStructure_SelectAllByQueryAsset(int queryAssetID, string connectionKey)
        {
            return DUtility_Asset_XMissionStructure.SelectAllByQueryAsset(queryAssetID, connectionKey);
        }

        [WebMethod]
        public void Utility_Asset_XMissionStructure_Update(Int32 structureID, Int32 projectID,
                                                           Int32 XMissionStructures_TopTypeID, double Latitude,
                                                           double Logitude, double Alititude, Int32 SatelliteCount,
                                                           DateTime SatelliteTime, bool SolutionAvaible, Int32 Handheld,
                                                           Int32 contactID, DateTime date, int countImages,
                                                           int utilityFK, string connectionKey)
        {
            DUtility_Asset_XMissionStructure.Update(structureID, projectID, XMissionStructures_TopTypeID, Latitude,
                                                    Logitude, Alititude, SatelliteCount, SatelliteTime, SolutionAvaible,
                                                    Handheld, contactID, date, countImages, utilityFK, connectionKey);

        }

        #endregion

        #region Utility_Asset_XMissionStructure_Image

        [WebMethod]
        public void Utility_Asset_XMissionStructure_Image_Disassociate(int imageID, string connectionKey)
        {
            DUtility_Asset_XMissionStructure_Image.Disassociate(imageID,connectionKey);
        }

        [WebMethod]
        public void Utility_Asset_XMissionStructure_Image_DisassociatePole(int poleId, string connectionKey)
        {
            DUtility_Asset_XMissionStructure_Image.DisassociatePole(poleId, connectionKey);
        }

        [WebMethod]
        public void Utility_Asset_XMissionStructure_Image_Associate(int imageId, int poleId, string connectionKey)
        {
            DUtility_Asset_XMissionStructure_Image.Associate(imageId, poleId, connectionKey);
        }

        [WebMethod]
        public int Utility_Asset_XMissionStructure_Image_Insert(int utilityId, bool solutionAvaible, string fileName,
                                                                byte[] bytes, double latitude, double altitude,
                                                                double longitude, DateTime satelliteTime,
                                                                int satelliteCount, double direction, int poleId, string connectionKey)
        {
            return
                DUtility_Asset_XMissionStructure_Image.Insert(utilityId, solutionAvaible, fileName, bytes, latitude,
                                                              altitude, longitude, satelliteTime, satelliteCount,
                                                              direction, poleId, connectionKey);
        }

        [WebMethod]
        public void Utility_Asset_XMissionStructure_Image_Delete(Int32 imageId, string connectionKey)
        {
            DUtility_Asset_XMissionStructure_Image.Delete(imageId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Asset_XMissionStructure_Image_SelectAll(Int32 offset, string connectionKey)
        {
            return DUtility_Asset_XMissionStructure_Image.SelectAll(offset, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Asset_XMissionStructure_Image_SelectAllByUtility(Int32 utility, string connectionKey)
        {
            return DUtility_Asset_XMissionStructure_Image.SelectAllByUtility(utility, connectionKey);
        }

        #endregion

        #region Utility_Asset_XMisssionStructure_Pole

        [WebMethod]
        public Int32 Utility_Asset_XMisssionStructure_Pole_Insert(Int32 utilityID,
                                                                  Int32 XMissionStructures_PoleTopTypeID,
                                                                  Int32 XMissionStructures_PoleSpeciesID,
                                                                  Int32 XMissionStructures_PoleTreatmentID, Int32 Year,
                                                                  Int32 XMissionStructures_PoleClassID, double Latitude,
                                                                  double Longitude, double Altitude,
                                                                  Int32 SatelliteCount, DateTime SatelliteTime,
                                                                  string AID, Int32 LVisit, string Number, double Length,
                                                                  string LVisitor, bool SolutionAvaible, string connectionKey)
        {
            return
                DUtility_Asset_XMissionStructure_Pole.Insert(utilityID, XMissionStructures_PoleTopTypeID,
                                                             XMissionStructures_PoleSpeciesID,
                                                             XMissionStructures_PoleTreatmentID, Year,
                                                             XMissionStructures_PoleClassID, Latitude, Longitude,
                                                             Altitude, SatelliteCount, SatelliteTime, AID, LVisit,
                                                             Number, Length, LVisitor, SolutionAvaible,connectionKey);
        }

        [WebMethod]
        public void Utility_Asset_XMisssionStructure_Pole_Update(Int32 poleID, Int32 utilityID,
                                                                 Int32 XMissionStructures_PoleTopTypeID,
                                                                 Int32 XMissionStructures_PoleSpeciesID,
                                                                 Int32 XMissionStructures_PoleTreatmentID, Int32 Year,
                                                                 Int32 XMissionStructures_PoleClassID, double Latitude,
                                                                 double Longitude, double Altitude, Int32 SatelliteCount,
                                                                 DateTime SatelliteTime, string AID, Int32 LVisit,
                                                                 string Number, double Length, string LVisitor,
                                                                 bool SolutionAvaible, string connectionKey)
        {
            DUtility_Asset_XMissionStructure_Pole.Update(poleID, utilityID, XMissionStructures_PoleTopTypeID,
                                                         XMissionStructures_PoleSpeciesID,
                                                         XMissionStructures_PoleTreatmentID, Year,
                                                         XMissionStructures_PoleClassID, Latitude, Longitude, Altitude,
                                                         SatelliteCount, SatelliteTime, AID, LVisit, Number, Length,
                                                         LVisitor, SolutionAvaible, connectionKey);
        }

        [WebMethod]
        public void Utility_Asset_XMisssionStructure_Pole_Delete(Int32 poleID, string connectionKey)
        {
            DUtility_Asset_XMissionStructure_Pole.Delete(poleID, connectionKey);
        }

        #endregion

        #region Utility_Polygno

        #region Query

        [WebMethod]
        public DataSet Utility_Polygon_SelectCRUD(Int32 utility_PolygonId, string connectionKey)
        {
            return DUtility_Polygon.SelectCRUD(utility_PolygonId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Polygon_SelectAllIdName(string connectionKey)
        {
            return DUtility_Polygon.SelectAllStaticIdName(connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Polygon_SelectAllView(string connectionKey)
        {
            return DUtility_Polygon.SelectAllView(connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Polygon_SelectAllTree(string connectionKey)
        {
            return DUtility_Polygon.SelectAllTree(connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Polygon_SelectAllByQuery(Int32 utility_QueryPolygonFk, string connectionKey)
        {
            return DUtility_Polygon.SelectAllByQuery(utility_QueryPolygonFk, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Polygon_SelectAll(string connectionKey)
        {
            return DUtility_Polygon.SelectAll(connectionKey);
        }

        [WebMethod]
        public bool Utility_Polygon_GetDeletesQuery(Int32 utility_PolygonId, string connectionKey)
        {
            return DUtility_Polygon.GetDeletesQuery(utility_PolygonId, connectionKey);
        }

        #endregion

        #region CRUD

        [WebMethod]
        public Int32 Utility_Polygon_Insert(string name, double altitude, double north, double east, double south,
                                            double west, Int32 utility_Polygon_ParentPolygonFk,
                                            Int32 utility_Polygon_PolygonTypeFk, Int32 lineColor, Int32 lineWidth,
                                            Int32 fillColor, Int32 fillOpacity, Int32 fontColor, string font, string connectionKey)
        {
            return
                DUtility_Polygon.Insert(name, altitude, north, east, south, west, utility_Polygon_ParentPolygonFk,
                                        utility_Polygon_PolygonTypeFk, lineColor, lineWidth, fillColor, fillOpacity,
                                        fontColor, font, connectionKey);
        }

        [WebMethod]
        public void Utility_Polygon_Update(Int32 utility_PolygonId, string name, double altitude, double north,
                                           double east, double south, double west, Int32 utility_Polygon_ParentPolygonFk,
                                           Int32 utility_Polygon_PolygonTypeFk, Int32 lineColor, Int32 lineWidth,
                                           Int32 fillColor, Int32 fillOpacity, Int32 fontColor, string font, string connectionKey)
        {
            DUtility_Polygon.Update(utility_PolygonId, name, altitude, north, east, south, west,
                                    utility_Polygon_ParentPolygonFk, utility_Polygon_PolygonTypeFk, lineColor, lineWidth,
                                    fillColor, fillOpacity, fontColor, font, connectionKey);
        }

        [WebMethod]
        public void Utility_Polygon_Delete(Int32 utility_PolygonId, string connectionKey)
        {
            DUtility_Polygon.Delete(utility_PolygonId, connectionKey);
        }

        #endregion

        #endregion

        #region Utility_Polygon_Point

        #region Query

        [WebMethod]
        public DataSet Utility_Polygon_Point_SelectAllByPolygon(Int32 Utility_PolygonId, string connectionKey)
        {
            return DUtility_Polygon_Point.SelectAllByPolygon(Utility_PolygonId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Polygon_Point_SelectAll(string connectionKey)
        {
            return DUtility_Polygon_Point.SelectAll(connectionKey);
        }

        #endregion

        #region CRUD

        [WebMethod]
        public Int32 Utility_Polygon_Point_Insert(Int32 utility_PolygonFK, double latitude, double longitude, string connectionKey)
        {
            return DUtility_Polygon_Point.Insert(utility_PolygonFK, latitude, longitude, connectionKey);
        }

        [WebMethod]
        public void Utility_Polygon_Point_Delete(Int32 utility_Polygon_PointId, string connectionKey)
        {
            DUtility_Polygon_Point.Delete(utility_Polygon_PointId, connectionKey);
        }

        [WebMethod]
        public void Utility_Polygon_Point_DeleteByPolygon(Int32 utility_PolygonFk, string connectionKey)
        {
            DUtility_Polygon_Point.DeleteByPolygon(utility_PolygonFk, connectionKey);
        }

        #endregion

        #endregion

        #region Utility_Polygon_PolygonType

        [WebMethod]
        public DataSet Utility_Polygon_PolygonType_SelectAllIdName(string connectionkey)
        {
            return DUtility_Polygon_PolygonType.SelectAllIdName(connectionkey);
        }

        #endregion

        #region Utility_Project

        [WebMethod]
        public DataSet Utility_Project_SelectAllIdName(string connectionKey)
        {
            return DUtility_Project.SelectAllIdName(connectionKey);
        }

        #endregion

        #region Utility_Query_Type

        [WebMethod]
        public DataSet Utility_Query_Type_SelectAllIdName(string connectionkey)
        {
            return DUtility_Query_Type.SelectAllIdName(connectionkey);
        }

        #endregion

        #region Utility_Query_Asset

        #region Query

        [WebMethod]
        public DataSet Utility_Query_Asset_SelectCRUD(Int32 utility_QueryAssetId, string connectionKey)
        {
            return DUtility_QueryAsset.SelectCRUD(utility_QueryAssetId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Query_Asset_ExecuteQuery_XMission(Int32 queryAssetFK, string connectionKey)
        {
            return DUtility_QueryAsset.ExecuteQuery_XMission(queryAssetFK, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Query_Asset_SellectAll_ContactQueries(Int32 contactFK, string connectionKey)
        {
            return DUtility_QueryAsset.SellectAll_ContactQueries(contactFK, connectionKey);
        }

        [WebMethod]
        public DataSet SelectAll(string connectionKey)
        {
            return DUtility_QueryAsset.SelectAll(connectionKey);
        }

        #endregion

        #region CrossTables

        [WebMethod]
        public DataSet Utility_Query_Asset_SelectYears(Int32 utility_QueryAssetId, string connectionKey)
        {
            return DUtility_QueryAsset.SelectYears(utility_QueryAssetId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Query_Asset_SelectTopTypes(Int32 utility_QueryAssetId, string connectionKey)
        {
            return DUtility_QueryAsset.SelectTopTypes(utility_QueryAssetId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Query_Asset_SelectPoleTopTypes(Int32 utility_QueryAssetId, string connectionKey)
        {
            return DUtility_QueryAsset.SelectPoleTopTypes(utility_QueryAssetId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Query_Asset_SelectPoleSpecies(Int32 utility_QueryAssetId, string connectionKey)
        {
            return DUtility_QueryAsset.SelectPoleSpecies(utility_QueryAssetId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Query_Asset_SelectProjects(Int32 utility_QueryAssetId, string connectionKey)
        {
            return DUtility_QueryAsset.SelectProjects(utility_QueryAssetId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Query_Asset_SelectPoleTreatments(Int32 utility_QueryAssetId, string connectionKey)
        {
            return DUtility_QueryAsset.SelectPoleTreatments(utility_QueryAssetId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Query_Asset_SelectPoleClasses(Int32 utility_QueryAssetId, string connectionKey)
        {
            return DUtility_QueryAsset.SelectPoleClasses(utility_QueryAssetId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Query_Asset_SelectVendors(Int32 utility_QueryAssetId, string connectionKey)
        {
            return DUtility_QueryAsset.SelectVendors(utility_QueryAssetId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Query_Asset_SelectAssets(Int32 utility_QueryAssetId, string connectionKey)
        {
            return DUtility_QueryAsset.SelectAssets(utility_QueryAssetId, connectionKey);
        }

        #endregion

        #region CRUD

        [WebMethod]
        public Int32 Utility_Query_Asset_Insert(Int32 utilityFK, Int32 utility_Query_TypeFK, Int32 utility_ContactFK,
                                                string name, string color, Int32 textToShow, bool showLineParents, string connectionKey)
        {
            return
                DUtility_QueryAsset.Insert(utilityFK, utility_Query_TypeFK, utility_ContactFK, name, color, textToShow,
                                           showLineParents, connectionKey);
        }

        [WebMethod]
        public void Utility_Query_Asset_Update(Int32 utility_QueryAssetId, Int32 utilityFK, Int32 utility_Query_TypeFK,
                                               Int32 utility_ContactFK, string name, string color, Int32 textToShow,
                                               bool showLineParents, string connectionKey)
        {
            DUtility_QueryAsset.Update(utility_QueryAssetId, utilityFK, utility_Query_TypeFK, utility_ContactFK, name,
                                       color, textToShow, showLineParents, connectionKey);
        }

        [WebMethod]
        public void Utility_Query_Asset_Delete(Int32 Utility_QueryAssetId, string connectionKey)
        {
            DUtility_QueryAsset.Delete(Utility_QueryAssetId, connectionKey);
        }

        #endregion

        #endregion

        #region Utility_Query_Polygon

        #region Query

        [WebMethod]
        public DataSet Utility_Query_Polygon_SelectCRUD(Int32 utility_QueryPolygonId, string connectionKey)
        {
            return DUtility_QueryPolygon.SelectCRUD(utility_QueryPolygonId, connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Query_Polygon_SelectAll(string connectionKey)
        {
            return DUtility_QueryPolygon.SelectAll(connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Query_Polygon_Execute(Int32 utility_QueryPolygonId, string connectionKey)
        {
            return DUtility_QueryPolygon.Execute(utility_QueryPolygonId, connectionKey);
        }

        #endregion

        #region CRUD

        [WebMethod]
        public Int32 Utility_Query_Polygon_Insert(string Name, Int32 utility_Query_TypeFK, bool points, double altitude,
                                                  Int32 lineColor, Int32 lineWidth, Int32 fillColor, Int32 fillOpacity,
                                                  Int32 fontColor, string font, string connectionKey)
        {
            return
                DUtility_QueryPolygon.Insert(Name, utility_Query_TypeFK, points, altitude, lineColor, lineWidth,
                                             fillColor, fillOpacity, fontColor, font, connectionKey);
        }

        [WebMethod]
        public void Utility_Query_Polygon_Update(Int32 utility_QueryPolygonId, string name, Int32 utility_Query_TypeFK,
                                                 bool points, double altitude, Int32 lineColor, Int32 lineWidth,
                                                 Int32 fillColor, Int32 fillOpacity, Int32 fontColor, string font, string connectionKey
                                                 )
        {
            DUtility_QueryPolygon.Update(utility_QueryPolygonId, name, utility_Query_TypeFK, points, altitude, lineColor,
                                         lineWidth, fillColor, fillOpacity, fontColor, font, connectionKey);
        }

        [WebMethod]
        public Int32 Utility_Query_Polygon_InsertPolygon(Int32 utility_QueryPolygonFK, Int32 utility_PolygonFK, string connectionKey)
        {
            return DUtility_QueryPolygon.InsertPolygon(utility_QueryPolygonFK, utility_PolygonFK, connectionKey);
        }

        [WebMethod]
        public void Utility_Query_Polygon_DeletePolygons(Int32 utility_QueryPolygonFk, string connectionKey)
        {
            DUtility_QueryPolygon.DeletePolygons(utility_QueryPolygonFk, connectionKey);
        }

        [WebMethod]
        public void Utility_Query_Polygon_Delete(Int32 utility_QueryPolygonId, string connectionKey)
        {
            DUtility_QueryPolygon.Delete(utility_QueryPolygonId, connectionKey);
        }

        #endregion

        #endregion

        #region Utility_Query_Polygon_Points

        #region Query

        [WebMethod]
        public DataSet Utility_Query_Polygon_Points_SelectAllByQuery(Int32 Utility_QueryPolygonId, string connectionKey)
        {
            return DUtility_QueryPolygon_Point.SelectAllByQuery(Utility_QueryPolygonId,connectionKey);
        }

        [WebMethod]
        public DataSet Utility_Query_Polygon_Points_SelectAll(string connectionKey)
        {
            return DUtility_QueryPolygon_Point.SelectAll(connectionKey);
        }

        #endregion

        #region CRUD

        [WebMethod]
        public Int32 Utility_Query_Polygon_Points_Insert(Int32 utility_QueryPolygonFK, double latitude, double longitude, string connectionKey)
        {
            return DUtility_QueryPolygon_Point.Insert(utility_QueryPolygonFK, latitude, longitude, connectionKey);
        }

        [WebMethod]
        public void Utility_Query_Polygon_Points_Delete(Int32 utility_QueryPolygon_PointId, string connectionKey)
        {
            DUtility_QueryPolygon_Point.Delete(utility_QueryPolygon_PointId, connectionKey);
        }

        [WebMethod]
        public void Utility_Query_Polygon_Points_DeleteByQuery(Int32 utility_QueryPolygonFk, string connectionKey)
        {
            DUtility_QueryPolygon_Point.DeleteByQuery(utility_QueryPolygonFk, connectionKey);
        }

        #endregion

        #endregion

        #region Vendor

        [WebMethod]
        public DataSet Vendor_SelectData(Int32 VendorID, string connectionKey)
        {
            return DVendor.SelectData(VendorID, connectionKey);
        }

        [WebMethod]
        public DataSet Vendor_SelectAllIdName(string connectionKey)
        {
            return DVendor.SelectAllIdName(connectionKey);
        }

        #endregion

        #region Vendor_Contacts

        [WebMethod]
        public DataSet Vendor_Contacts_SelectAllIdNameByVendor(int vendorID, string connectionKey)
        {
            return DVendor_Contacts.SelectAllIdNameByVendor(vendorID,connectionKey);
        }

        #endregion

        #region Vendor_Project

        [WebMethod]
        public DataSet Vendor_Project_SelectData(Int32 Vendor_ProjectID, string connectionKey)
        {
            return DVendor_Project.SelectData(Vendor_ProjectID, connectionKey);
        }

        [WebMethod]
        public DataSet Vendor_Project_SelectAllIdName(string connectionKey)
        {
            return DVendor_Project.SelectAllIdName(connectionKey);
        }

        [WebMethod]
        public DataSet Vendor_Project_SelectAllIdNameByVendor(int vendorID, string connectionKey)
        {
            return DVendor_Project.SelectAllIdNameByVendor(vendorID, connectionKey);
        }

        [WebMethod]
        public DataSet Vendor_Project_SelectAll(string connectionKey)
        {
            return DVendor_Project.SelectAll(connectionKey);
        }

        #endregion

        #region Vendor_Visit_Type

        [WebMethod]
        public DataSet Vendor_Visit_Type_SelectAllIdName(string connectionKey)
        {
            return DVendor_Visit_Type.SelectAllIdName(connectionKey);
        }

        #endregion

        #region Vendor_Visit_XMission_Structure

        #region Query

        [WebMethod]
        public DataSet Vendor_Visit_XMission_Structure_GetServerVisits(string connectionKey)
        {
            return DVendor_Visit_XMissionStructure.GetServerVisits(connectionKey);
        }

        [WebMethod]
        public DataSet Vendor_Visit_XMission_Structure_GetServerVisitsByID(int structureID, string connectionKey)
        {
            return DVendor_Visit_XMissionStructure.GetServerVisitsByID(structureID, connectionKey);
        }

        [WebMethod]
        public DataSet Vendor_Visit_XMission_Structure_GetServerVisitsByQueryAsset(int queryAsset, string connectionKey)
        {
            return DVendor_Visit_XMissionStructure.GetServerVisitsByQueryAsset(queryAsset, connectionKey);
        }

        [WebMethod]
        public int Vendor_Visit_XMission_Structure_GetTotal(string connectionKey)
        {
            return DVendor_Visit_XMissionStructure.GetTotal(connectionKey);
        }

        [WebMethod]
        public DataSet Vendor_Visit_Xmission_Structure_GetServerVisitsByUtilityID(int utilityid, string connectionKey)
        {
            return DVendor_Visit_XMissionStructure.GetServerVisitsByUtilityID(utilityid, connectionKey);
        }

        #endregion

        #region CRUD

        [WebMethod]
        public Int32 Vendor_Visit_XMission_Structure_Insert(Int32 Vendor_ProjectID,
                                                            Int32 Utility_Asset_XMissionStructureID,
                                                            Int32 Vendor_Visit_TypeID,
                                                            Int32 XMissionStructures_TopTypeID, double Latitude,
                                                            double Logitude, double Alititude, Int32 SatelliteCount,
                                                            DateTime SatelliteTime, bool SolutionAvaible, Int32 Handheld,
                                                            Int32 Vendor_ContactID, DateTime date, int countImages, string connectionKey)
        {
            return
                DVendor_Visit_XMissionStructure.Insert(Vendor_ProjectID, Utility_Asset_XMissionStructureID,
                                                       Vendor_Visit_TypeID, XMissionStructures_TopTypeID, Latitude,
                                                       Logitude, Alititude, SatelliteCount, SatelliteTime,
                                                       SolutionAvaible, Handheld, Vendor_ContactID, date, countImages, connectionKey);
        }

        [WebMethod]
        public void Vendor_Visit_XMission_Structure_Update(Int32 structureID, Int32 Vendor_ProjectID,
                                                           Int32 Utility_Asset_XMissionStructureID,
                                                           Int32 Vendor_Visit_TypeID, Int32 XMissionStructures_TopTypeID,
                                                           double Latitude, double Logitude, double Alititude,
                                                           Int32 SatelliteCount, DateTime SatelliteTime,
                                                           bool SolutionAvaible, Int32 Handheld, Int32 Vendor_ContactID,
                                                           DateTime date, int countImages, string connectionKey)
        {
            DVendor_Visit_XMissionStructure.Update(structureID, Vendor_ProjectID, Utility_Asset_XMissionStructureID,
                                                   Vendor_Visit_TypeID, XMissionStructures_TopTypeID, Latitude, Logitude,
                                                   Alititude, SatelliteCount, SatelliteTime, SolutionAvaible, Handheld,
                                                   Vendor_ContactID, date, countImages, connectionKey);
        }

        [WebMethod]
        public void Vendor_Visit_XMission_Structure_Delete(int structureID, string connectionKey)
        {
            DVendor_Visit_XMissionStructure.Delete(structureID, connectionKey);
        }

        [WebMethod]
        public void Vendor_Visit_XMission_Structure_UpdateUtility(int structureID, int utilityId, string connectionKey)
        {
            DVendor_Visit_XMissionStructure.UpdateUtility(structureID, utilityId, connectionKey);
        }

        #endregion

        #endregion

        #region Vendor_Visit_XMissionStructures_Image

        #region Query

        [WebMethod]
        public DataSet Vendor_Visit_XMissionStructures_Image_GetServerImages(int offset, string connectionKey)
        {
            return DVendor_Visit_XMissionStructures_Image.GetServerImages(offset, connectionKey);
        }

        [WebMethod]
        public DataSet Vendor_Visit_XMissionStructures_Image_GetByStructureID(int structureID, string connectionKey)
        {
            return DVendor_Visit_XMissionStructures_Image.GetByStructureID(structureID, connectionKey);
        }

        [WebMethod]
        public int Vendor_Visit_XMissionStructures_Image_VerifyExistence(int imageID, int poleId, int structureID, string connectionKey)
        {
            return DVendor_Visit_XMissionStructures_Image.VerifyExistence(imageID, poleId, structureID, connectionKey);
        }

        [WebMethod]
        public int Vendor_Visit_XMissionStructures_Image_GetFreePosition(int imageID, int structureID, string connectionKey)
        {
            return DVendor_Visit_XMissionStructures_Image.GetFreePosition(imageID, structureID, connectionKey);
        }

        [WebMethod]
        public int Vendor_Visit_XMissionStructures_Image_GetTotal(string connectionKey)
        {
            return DVendor_Visit_XMissionStructures_Image.GetTotal(connectionKey);
        }

        #endregion

        #region CRUD

        [WebMethod]
        public int Vendor_Visit_XMissionStructures_Image_Insert(int vendor_Visit_XMissionStructureFK,
                                                                bool solutionAvaible, string fileName, byte[] bytes,
                                                                double latitude, double altitude, double longitude,
                                                                DateTime satelliteTime, int satelliteCount,
                                                                double direction,
                                                                int vendor_Visit_XMissionStructures_PoleID,
                                                                string connectionKey)
        {

            int imageId = DVendor_Visit_XMissionStructures_Image.Insert(vendor_Visit_XMissionStructureFK, solutionAvaible,
                                                              fileName, bytes, latitude, altitude, longitude,
                                                              satelliteTime, satelliteCount, direction,
                                                              vendor_Visit_XMissionStructures_PoleID,connectionKey);
            return imageId;
        }

        [WebMethod]
        public void Vendor_Visit_XMissionStructures_Image_InsertExistingImage(bool solutionAvaible, string fileName,
                                                                              double latitude, double altitude,
                                                                              double longitude, DateTime satelliteTime,
                                                                              int satelliteCount, double direction,
                                                                              int vendor_Visit_XMissionStructures_PoleID,
                                                                              int originalImageId, string connectionKey)
        {
            DVendor_Visit_XMissionStructures_Image.InsertExistingImage(solutionAvaible, fileName, latitude, altitude,
                                                                       longitude, satelliteTime, satelliteCount,
                                                                       direction, vendor_Visit_XMissionStructures_PoleID,
                                                                       originalImageId, connectionKey);
        }

        [WebMethod]
        public void Vendor_Visit_XMissionStructures_Image_UpdatePoleReference(bool solutionAvaible, double latitude,
                                                                              double altitude, double longitude,
                                                                              DateTime satelliteTime, int satelliteCount,
                                                                              double direction,
                                                                              int vendor_Visit_XMissionStructures_PoleID,
                                                                              int originalImageId, string connectionKey)
        {
            DVendor_Visit_XMissionStructures_Image.UpdatePoleReference(solutionAvaible, latitude, altitude, longitude,
                                                                       satelliteTime, satelliteCount, direction,
                                                                       vendor_Visit_XMissionStructures_PoleID,
                                                                       originalImageId, connectionKey);
        }

        [WebMethod]
        public void Vendor_Visit_XMissionStructures_Image_Delete(int imageID, string connectionKey)
        {
            DVendor_Visit_XMissionStructures_Image.Delete(imageID,connectionKey);
        }

        #endregion

        #endregion

        #region Vendor_Visit_XMissionStructures_Pole

        #region Query

        [WebMethod]
        public DataSet Vendor_Visit_XMissionStructures_Pole_GetServerPoles(string connectionKey)
        {
            return DVendor_Visit_XMissionStructures_Pole.GetServerPoles(connectionKey);
        }

        [WebMethod]
        public DataSet Vendor_Visit_XMissionStructures_Pole_GetByStructureID(int structureID, string connectionKey)
        {
            return DVendor_Visit_XMissionStructures_Pole.GetByStructureID(structureID,connectionKey);
        }

        [WebMethod]
        public int Vendor_Visit_XMissionStructures_Pole_GetTotal(string connectionKey)
        {
            return DVendor_Visit_XMissionStructures_Pole.GetTotal(connectionKey);
        }

        #endregion

        #region CRUD

        [WebMethod]
        public Int32 Vendor_Visit_XMissionStructures_Pole_Insert(Int32 Vendor_Visit_XMissionStructureID,
                                                                 Int32 XMissionStructures_PoleTopTypeID,
                                                                 Int32 XMissionStructures_PoleSpeciesID,
                                                                 Int32 XMissionStructures_PoleTreatmentID, Int32 Year,
                                                                 Int32 XMissionStructures_PoleClassID, double Latitude,
                                                                 double Longitude, double Altitude, Int32 SatelliteCount,
                                                                 DateTime SatelliteTime, string AID, Int32 LVisit,
                                                                 string Number, double Length, string LVisitor,
                                                                 bool SolutionAvaible, string connectionKey)
        {
            return
                DVendor_Visit_XMissionStructures_Pole.Insert(Vendor_Visit_XMissionStructureID,
                                                             XMissionStructures_PoleTopTypeID,
                                                             XMissionStructures_PoleSpeciesID,
                                                             XMissionStructures_PoleTreatmentID, Year,
                                                             XMissionStructures_PoleSpeciesID, Latitude, Longitude,
                                                             Altitude, SatelliteCount, SatelliteTime, AID, LVisit,
                                                             Number, Length, LVisitor, SolutionAvaible,connectionKey);
        }

        [WebMethod]
        public void Vendor_Visit_XMissionStructures_Pole_Update(Int32 poleID, Int32 Vendor_Visit_XMissionStructureID,
                                                                Int32 XMissionStructures_PoleTopTypeID,
                                                                Int32 XMissionStructures_PoleSpeciesID,
                                                                Int32 XMissionStructures_PoleTreatmentID, Int32 Year,
                                                                Int32 XMissionStructures_PoleClassID, double Latitude,
                                                                double Longitude, double Altitude, Int32 SatelliteCount,
                                                                DateTime SatelliteTime, string AID, Int32 LVisit,
                                                                string Number, double Length, string LVisitor,
                                                                bool SolutionAvaible, string connectionKey)
        {
            DVendor_Visit_XMissionStructures_Pole.Update(poleID, Vendor_Visit_XMissionStructureID,
                                                         XMissionStructures_PoleTopTypeID,
                                                         XMissionStructures_PoleSpeciesID,
                                                         XMissionStructures_PoleTreatmentID, Year,
                                                         XMissionStructures_PoleClassID, Latitude, Longitude, Altitude,
                                                         SatelliteCount, SatelliteTime, AID, LVisit, Number, Length,
                                                         LVisitor, SolutionAvaible,connectionKey);
        }

        [WebMethod]
        public void Vendor_Visit_XMissionStructures_Pole_Delete(Int32 poleID, string connectionKey)
        {
            DVendor_Visit_XMissionStructures_Pole.Delete(poleID,connectionKey);
        }

        [WebMethod]
        public void Vendor_Visit_XMissionStructures_Pole_DesasocciateImages(Int32 poleID, string connectionKey)
        {
            DVendor_Visit_XMissionStructures_Pole.DesasocciateImages(poleID,connectionKey);
        }

        #endregion

        #endregion

        #region XMissionStructures_TopType

        [WebMethod]
        public DataSet XMissionStructures_TopType_SelectAllIdName(string connectionKey)
        {
            return DXMissionStructures_TopType.SelectAllIdName(connectionKey);
        }
        [WebMethod]
        public DataSet XMissionStructures_TopType_SelectAllIdNameByType(int type, string connectionKey)
        {
            return DXMissionStructures_TopType.SelectAllIdNameByType(type, connectionKey);
        }

        #endregion

        #region XMissionStructures_PoleSpecies

        [WebMethod]
        public DataSet XMissionStructures_PoleSpecies_SelectAllIdName(string connectionKey)
        {
            return DXMissionStructures_PoleSpecies.SelectAllIdName(connectionKey);
        }

        #endregion

        #region XMissionStructures_PoleTreatments

        [WebMethod]
        public DataSet XMissionStructures_PoleTreatments_SelectAllIdName(string connectionKey)
        {
            return DXMissionStructures_PoleTreatments.SelectAllIdName(connectionKey);
        }

        #endregion

        #region XMissionStructures_PoleTopType

        [WebMethod]
        public DataSet XMissionStructures_PoleTopType_SelectAllIdName(string connectionKey)
        {
            return DXMissionStructures_PoleTopType.SelectAllIdName(connectionKey);
        }

        #endregion

        #region XMissionStructures_PoleClass
        [WebMethod]
        public DataSet XMissionStructures_PoleClass_SelectAllIdName(string connectionKey)
        {
            return DXMissionStructures_PoleClass.SelectAllIdName(connectionKey);
        }

        #endregion


        #region Handheld

        [WebMethod]
        public DataSet Handheld_SelectAllIdName(string connectionKey)
        {
            return DHandheld.SelectAllIdName(connectionKey);
        }

        [WebMethod]
        public int Handheld_Insert(string code, string connectionKey)
        {
            return DHandheld.Insert(code, connectionKey);
        }

        [WebMethod]
        public DataSet Handheld_Select(int id, string connectionKey)
        {
            return DHandheld.Select(id, connectionKey);
        }

        #endregion

        #region CentralOffice

        [WebMethod]
        public DataSet CentralOffice_SelectAll(string connection)
        {
            return DCentralOffice.SelectAll(connection);
        }

        #endregion

        #region Settings

        [WebMethod]
        public DataSet Settings_SelectKml(string connectionKey)
        {
            return DSettings.SelectKml(connectionKey);
        }
        [WebMethod]
        public void Settings_Update(int id, string value, string connectionKey)
        {
            DSettings.Update(id,value,connectionKey);
        }
        [WebMethod]
        public DataSet Settings_SelectByKey(string key, string connectionKey)
        {
            return DSettings.SelectByKey(key, connectionKey);
        }

        #endregion






        //#region Select

        ////[WebMethod]
        ////public DataSet GetServer_Vendor_Visit_XMissionStructures()
        ////{
        ////    return DVendor_Visit_XMissionStructure.GetServerVisits();
        ////}
        ////[WebMethod]
        ////public DataSet GetServer_Vendor_Visit_XMissionStructures_Poles()
        ////{
        ////    return DVendor_Visit_XMissionStructures_Pole.GetServerPoles();
        ////}
        ////[WebMethod]
        ////public DataSet GetServer_Vendor_Visit_XMissionStructures_Images(int offset)
        ////{
        ////    return DVendor_Visit_XMissionStructures_Image.GetServerImages(offset);
        ////}
        ////[WebMethod]
        ////public DataSet GetServer_Utility_DUtility_QueryAsset_SellectAll_ContactQueries(Int32 ContactFK)
        ////{
        ////    return DUtility_QueryAsset.SellectAll_ContactQueries(ContactFK);
        ////}
        ////[WebMethod]
        ////public DataSet GetServer_Utility_DUtility_QueryAsset_ExecuteQuery_XMission(Int32 QueryAssetFK)
        ////{
        ////    return DUtility_QueryAsset.ExecuteQuery_XMission(QueryAssetFK);
        ////}
        ////[WebMethod]
        ////public byte[] GetServer_Vendor_Visit_XMissionStructures_ImageBytes(int IdImage)
        ////{
        ////    return DVendor_Visit_XMissionStructures_Image.GetServerImageBytes(IdImage);
        ////}


        //[WebMethod]
        //public DataSet GetServer_Vendor_Project_SelectAllIdName()
        //{
        //    return DVendor_Project.SelectAllIdName();
        //}

        //[WebMethod]
        //public DataSet GetServer_Vendor_Project_SelectData(int vendorProjectID)
        //{
        //    return DVendor_Project.SelectData(vendorProjectID);
        //}

        //[WebMethod]
        //public DataSet GetServer_Vendor_Visit_Type_SelectAllIdName()
        //{
        //    return DVendor_Visit_Type.SelectAllIdName();
        //}

        //[WebMethod]
        //public DataSet GetServer_XMissionStructures_PoleTopType_SelectAllIdName()
        //{
        //    return DXMissionStructures_PoleTopType.SelectAllIdName();
        //}

        //[WebMethod]
        //public DataSet GetServer_XMissionStructures_PoleSpecies_SelectAllIdName()
        //{
        //    return DXMissionStructures_PoleSpecies.SelectAllIdName();
        //}

        //[WebMethod]
        //public DataSet GetServer_XMissionStructures_PoleTreatments_SelectAllIdName()
        //{
        //    return DXMissionStructures_PoleTreatments.SelectAllIdName();
        //}

        //[WebMethod]
        //public DataSet GetServer_XMissionStructures_PoleClass_SelectAllIdName()
        //{
        //    return DXMissionStructures_PoleClass.SelectAllIdName();
        //}


        ////QUERYASSETS
        //[WebMethod]
        //public DataSet GetServer_Utility_QueryAssets()
        //{
        //    return DUtility_QueryAsset.SelectAll();
        //}

        ////QUERYPOLYGONS
        //[WebMethod]
        //public DataSet GetServer_Utility_QueryPolygons()
        //{
        //    return DUtility_QueryPolygon.SelectAll();
        //}

        ////POLYGONS
        //[WebMethod]
        //public DataSet GetServer_Utility_Polygons()
        //{
        //    return DUtility_Polygon.SelectAll();
        //}

        //#endregion

        //#region Insert

        //[WebMethod]
        //public int InsertImage(int vendor_Visit_XMissionStructureFK, bool solutionAvaible, string fileName, byte[] bytes,
        //                       double latitude, double altitude, double longitude, DateTime satelliteTime,
        //                       int satelliteCount, double direction, int vendor_Visit_XMissionStructures_PoleID)
        //{
        //    return
        //        DVendor_Visit_XMissionStructures_Image.Insert(vendor_Visit_XMissionStructureFK, solutionAvaible,
        //                                                      fileName, bytes, latitude, altitude, longitude,
        //                                                      satelliteTime, satelliteCount, direction,
        //                                                      vendor_Visit_XMissionStructures_PoleID,"BETA");
        //}

        //[WebMethod]
        //public int InsertPole(Int32 Vendor_Visit_XMissionStructureID, Int32 XMissionStructures_PoleTopTypeID,
        //                      Int32 XMissionStructures_PoleSpeciesID, Int32 XMissionStructures_PoleTreatmentID,
        //                      Int32 Year, Int32 XMissionStructures_PoleClassID, double Latitude, double Longitude,
        //                      double Altitude, Int32 SatelliteCount, DateTime SatelliteTime, string AID, Int32 LVisit,
        //                      string Number, double Length, string LVisitor, bool SolutionAvaible)
        //{
        //    return
        //        DVendor_Visit_XMissionStructures_Pole.Insert(Vendor_Visit_XMissionStructureID,
        //                                                     XMissionStructures_PoleTopTypeID,
        //                                                     XMissionStructures_PoleSpeciesID,
        //                                                     XMissionStructures_PoleTreatmentID, Year,
        //                                                     XMissionStructures_PoleClassID, Latitude, Longitude,
        //                                                     Altitude, SatelliteCount, SatelliteTime, AID, LVisit,
        //                                                     Number, Length, LVisitor, SolutionAvaible);
        //}

        //[WebMethod]
        //public int InsertStructure(Int32 Vendor_ProjectID, Int32 Vendor_Visit_TypeID, Int32 utility_MissionID,
        //                           Int32 topTypeID, double Latitude, double Logitude, double Alititude,
        //                           Int32 SatelliteCount, DateTime SatelliteTime, bool SolutionAvaible, Int32 Handheld,
        //                           DateTime date, int countImages)
        //{
        //    return
        //        DVendor_Visit_XMissionStructure.Insert(Vendor_ProjectID, utility_MissionID, Vendor_Visit_TypeID,
        //                                               topTypeID, Latitude, Logitude, Alititude, SatelliteCount,
        //                                               SatelliteTime, SolutionAvaible, Handheld, Int32.MinValue, date,
        //                                               countImages);
        //}

        //#endregion
    }
}